package com.yang.protocol;

/**
 * @Description: 发送消息的动作枚举(也就是我们定义的命令)
 * @author: Yang Qiang
 * @create: 2021-09-23 22:56
 */
public enum  MsgActionEnum {
    SYSTEM("SYSTEM","系统消息"),
    LOGIN("LOGIN","登录指令"),
    LOGOUT("LOGOUT","登出指令"),
    CHAT("CHAT","聊天消息"),
    FLOWER("FLOWER","送鲜花"),
    KEEPALIVE("KEEPALIVE","心跳检测"),

    ;
    private String name;// 命令类型
    private String msg;// 描述

    /**
     * 判断命令是否是我们规定的命令
     * String的matches方法:
     *      判断字符串中是否存在我们的指令
     * @param content
     * @return
     */
    public static boolean isIMP(String content){
        return content.matches("^\\[(SYSTEM|LOGIN|LOGOUT|CHAT|FLOWER)\\]");
    }

    MsgActionEnum(String name, String msg) {
        this.name = name;
        this.msg = msg;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getMsg() {
        return msg;
    }

    public void setMsg(String msg) {
        this.msg = msg;
    }
}
